import 'lead_guide_model.dart';

class ThingSmartALeadModel {
  final String? title;
  final String? iconUrl;
  final String? videoUrl;

  final bool radioFlag;

  ///< CheckBox display Switch
  final bool radioExplainFlag;

  ///< Checkbox Description Guidance Switch
  final bool guideFlag;

  ///< Assisted Guide Switch

  final int? guideType; // GuideType 1:Step lead 2:H5 page、3:Applet App
  final String? guideH5Url; // H5 URL
  final String? appletsPath; // Path of Applet App

  final String? addBtText; //Radio box text (multi-step)
  final String? radioExplainTitle; //Radio box explanation title (multi-step)
  final String? radioExplainDesc; //Radio box description (multi-step)
  final String? radioExplainIconUrl; // Icon URL
  final String? radioExplainVideoUrl; // Video URL
  final String? guideEntranceText; // Auxiliary guide entrance text (multi-step)
  final String? guideTitle; // Assisted guide first level title (multi-step)

  final List<ThingSmartALeadGuideModel>? guideList; // Auxiliary guide steps

  /// End-of-paring guide configuration
  final int?
  guideCloseType; // Step end jump page type 2:Jump H5 page 3:Jump applet 4:Direct close 5:Jump panel
  final String? closeGuideH5Url;
  final String? closeAppletsPath;
  final String? closePanelPath;

  ThingSmartALeadModel({
    this.title,
    this.iconUrl,
    this.videoUrl,
    this.radioFlag = false,
    this.radioExplainFlag = false,
    this.guideFlag = false,
    this.guideType,
    this.guideH5Url,
    this.appletsPath,
    this.addBtText,
    this.radioExplainTitle,
    this.radioExplainDesc,
    this.radioExplainIconUrl,
    this.radioExplainVideoUrl,
    this.guideEntranceText,
    this.guideTitle,
    this.guideList,
    this.guideCloseType,
    this.closeGuideH5Url,
    this.closeAppletsPath,
    this.closePanelPath,
  });
factory ThingSmartALeadModel.fromJson(Map<String, dynamic> json) {
  return ThingSmartALeadModel(
    title: json['title'] as String?,
    iconUrl: json['iconUrl'] as String?,
    videoUrl: json['videoUrl'] as String?,
    radioFlag: json['radioFlag'] as bool? ?? false,
    radioExplainFlag: json['radioExplainFlag'] as bool? ?? false,
    guideFlag: json['guideFlag'] as bool? ?? false,
    guideType: json['guideType'] as int?,
    guideH5Url: json['guideH5Url'] as String?,
    appletsPath: json['appletsPath'] as String?,
    addBtText: json['AddBtText'] as String?,
    radioExplainTitle: json['radioExplainTitle'] as String?,
    radioExplainDesc: json['radioExplainDesc'] as String?,
    radioExplainIconUrl: json['radioExplainIconUrl'] as String?,
    radioExplainVideoUrl: json['radioExplainVideoUrl'] as String?,
    guideEntranceText: json['guideEntranceText'] as String?,
    guideTitle: json['guideTitle'] as String?,
    guideList: json['guideList'] != null
        ? (json['guideList'] as List).map((e) {
            // 转换 Map<Object?, Object?> 到 Map<String, dynamic>
            final guideJson = e is Map<String, dynamic>
                ? e
                : Map<String, dynamic>.from(e as Map<dynamic, dynamic>);
            return ThingSmartALeadGuideModel.fromJson(guideJson);
          }).toList()
        : null,
    guideCloseType: json['guideCloseType'] as int?,
    closeGuideH5Url: json['closeGuideH5Url'] as String?,
    closeAppletsPath: json['closeAppletsPath'] as String?,
    closePanelPath: json['closePanelPath'] as String?,
  );
}

  Map<String, dynamic> toJson() {
    return {
      'title': title,
      'iconUrl': iconUrl,
      'videoUrl': videoUrl,
      'radioFlag': radioFlag,
      'radioExplainFlag': radioExplainFlag,
      'guideFlag': guideFlag,
      'guideType': guideType,
      'guideH5Url': guideH5Url,
      'appletsPath': appletsPath,
      'AddBtText': addBtText,
      'radioExplainTitle': radioExplainTitle,
      'radioExplainDesc': radioExplainDesc,
      'radioExplainIconUrl': radioExplainIconUrl,
      'radioExplainVideoUrl': radioExplainVideoUrl,
      'guideEntranceText': guideEntranceText,
      'guideTitle': guideTitle,
      'guideList': guideList?.map((e) => e.toJson()).toList(),
      'guideCloseType': guideCloseType,
      'closeGuideH5Url': closeGuideH5Url,
      'closeAppletsPath': closeAppletsPath,
      'closePanelPath': closePanelPath,
    };
  }
}
